package com.czy.owner.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;

import com.czy.owner.R;
import com.czy.owner.entity.WheelAttrModel;
import com.easyrecycleview.adapter.BaseViewHolder;
import com.easyrecycleview.adapter.RecyclerArrayAdapter;

/**
 * Created by Raven on 2017/12/22.
 */

public class WheelBrandAdapter extends RecyclerArrayAdapter<WheelAttrModel> {


        private Context context;

        public WheelBrandAdapter(Context context) {
            super(context);
            this.context = context;
        }


        @Override
        public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
            return new ClassifyHolder(parent);
        }

        class ClassifyHolder extends BaseViewHolder<WheelAttrModel> {
            private CheckBox cbClassify;
            private LinearLayout llItemRoot;
            public ClassifyHolder(ViewGroup parent) {
                super(parent, R.layout.item_classify_wheel_filter);
                cbClassify = $(R.id.cb_classify_item);
                llItemRoot = $(R.id.ll_item_root);
            }

            @Override
            public void setData(final WheelAttrModel model) {
                super.setData(model);
                cbClassify.setText(model.getName());
                cbClassify.setChecked(model.isChoosed());
                cbClassify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                        getAllData().get(getAdapterPosition()).setChoosed(b);
                    }
                });
            }
        }

}
